BUILD_DIR = ./src/
HEADER_PATH = -I./include
LIBS = -llapacke -llapack -lblas -lgfortran

CXX_SRC = $(wildcard ./src/*.cpp)
CXX__O = $(wildcard *.o)
CXX_OBJS = $(patsubst %cpp, %o, $(CXX_SRC))

ID = A
OPTIONS = -D _TEST__
ifneq ($(ID),A)
	OPTIONS = -D _TEST_$(ID)_
endif

MV = mv
TARGET = main
CXX_CLEAN = clean
CXXFLAGS = '-std=c++14' $(OPTIONS)

$(TARGET): $(CXX_OBJS)
	$(CXX) $^ -o $@ $(LIBS)

$(CXX_OBJS): $(CXX_SRC)
	$(CXX) $^ -c $(LIBS) $(CXXFLAGS) $(HEADER_PATH) && $(MV) $(notdir $(CXX_OBJS)) $(BUILD_DIR)

BASE = report
LATEX = doc
PDF = $(BASE).pdf
DVI = $(BASE).dvi
TEX = $(BASE).tex
LOG = $(BASE).log
AUX = $(BASE).aux
OUT = $(BASE).out
TEX_TYPE = xelatex
DVI_PDF = dvipdfm

$(LATEX): $(PDF)

$(PDF): $(DVI)
	$(DVI_PDF) $^ -o
	
$(DVI): $(TEX)
	$(TEX_TYPE) $^

.PHONY: $(CXX_CLEAN)
$(CXX_CLEAN):
	$(RM) $(CXX__O) $(TARGET) $(LOG) $(DVI) $(AUX) $(OUT) $(PDF)



